package com.qinggeng.project.system.service;

import com.qinggeng.project.api.dto.OrdersUserDto;
import com.qinggeng.project.system.domain.OrdersGoods;
import com.qinggeng.project.system.domain.vo.CourierRefundOrdersVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单商品Service接口
 *
 * @author qinggeng
 * @date 2020-06-17
 */
public interface IOrdersGoodsService
{
    /**
     * 查询订单商品
     *
     * @param ordersGoodsId 订单商品ID
     * @return 订单商品
     */
    public OrdersGoods selectOrdersGoodsById(Long ordersGoodsId);

    /**
     * 查询订单商品列表
     *
     * @param ordersGoods 订单商品
     * @return 订单商品集合
     */
    public List<OrdersGoods> selectOrdersGoodsList(OrdersGoods ordersGoods);

    /**
     * 新增订单商品
     *
     * @param ordersGoods 订单商品
     * @return 结果
     */
    public int insertOrdersGoods(OrdersGoods ordersGoods);

    /**
     * 修改订单商品
     *
     * @param ordersGoods 订单商品
     * @return 结果
     */
    public int updateOrdersGoods(OrdersGoods ordersGoods);

    /**
     * 批量删除订单商品
     *
     * @param ordersGoodsIds 需要删除的订单商品ID
     * @return 结果
     */
    public int deleteOrdersGoodsByIds(Long[] ordersGoodsIds);

    /**
     * 删除订单商品信息
     *
     * @param ordersGoodsId 订单商品ID
     * @return 结果
     */
    public int deleteOrdersGoodsById(Long ordersGoodsId);

    List<OrdersGoods> selectOrderGoodListByOrdersId(Long orderId);

    /**
     * 根据订单id集合查询所有相关的订单商品信息
     * @param orderIdList
     */
    List<OrdersGoods> selectOrderGoodListByOrdersIds(List<Long> orderIdList);

    /**
     * 根据订单ID计算订单的提成
     * @param ordersId
     * @return
     */
    BigDecimal getOrdersPercentageByOrdersId(Long ordersId);

    /**
     * 根据订单ID计算订单平均利润率
     * @param ordersId
     * @return
     */
    BigDecimal getOrdersAverageProfitRateByOrdersId(Long ordersId);

    /**
     * 根据商品主类计算购买人数
     * @param mainCategory
     * @return
     */
    Long getBuyUserNumByMainCategory(Long mainCategory);

    /**
     * s根据商品主类计算商品购买数量
     * @param mainCategory
     * @return
     */
    Long getOrdersGoodsNumByMainCategory(Long mainCategory);

    /**
     * 根据商品主类查询下单用户列表
     * @param mainCategory
     * @return
     */
    List<OrdersUserDto> listOrdersUserDto(Long mainCategory);


    /**
     * 根据 ordersGoodsId 查询 ,当前退单商品总价
     */
    BigDecimal calculation(Long ordersGoodsId, Long userId);


    /**
     * 修改为提交退款状态
     *
     */
    boolean  sigleItemRefund(Long  ordersGoodsId);


    /**
     * 同意退款
    */
    boolean sigleItemRefundAgree(Long ordersGoodsId);

    /**
     * 拒绝退款
     */
   boolean sigleItemRefundRefuse(Long ordersGoodsId) ;

    /**
     * 退款商品
     * @param orderIdList
     * @return
     */
   List<OrdersGoods> selectReturnOrderGoodListByOrdersIds(List<Long> orderIdList);

    /**
     * 根据orderId修改订单商品状态
     * @param ordersId
     * @return
     */
    boolean updateOrdersGoodsByOrdersId(Long ordersId);



    /**
     * 取消受理
     * @param
     * @return
     */
    boolean updateOrdersGoodsCancel(Long ordersGoodsId);

    /**
     * 检查订单商品是否已完结
     * @param ordersId
     * @return
     */
    boolean checkOrdersGoodsIsAllEnd(Long ordersId);

    /**
     * 设置订单商品利润和团长提成
     * @param buyPrice
     * @param ordersGoods
     * @return
     */
    OrdersGoods setProfitAndPercentage(BigDecimal buyPrice,OrdersGoods ordersGoods);

    List<CourierRefundOrdersVO> selectCourierRefundOrdersVOListByCourierId(Long courierId,String refundAplStatus);

    /**
     * 根据ordersId修改refundAplStatus
     * @param ordersGoodsId
     * @param refundAplStatus
     */
    boolean updateRefundAplStatusByordersId(Long ordersGoodsId, String refundAplStatus);

    boolean updateByRefundAplDelByordersGoodsId(Long ordersGoodsId, String refundAplDel);
}
